package cool.taomu.toolkit

import com.google.inject.Guice
import com.google.inject.Key
import com.google.inject.name.Names
import java.io.FileInputStream
import org.junit.jupiter.api.Test
import cool.taomu.toolkit.crypto.Base64

class ConfigFileTest {

    interface IService {
    }
    
     @Test
    def void c(){
        TaomuGuiceServiceLoader.load(IService,null)
    }

    @Test
    def void configTest() {
        var i = Guice.createInjector(new BaseModule(null))
        var key = Key.get(IService, Names.named("a"));
        if (i.getExistingBinding(key) !== null) {
            var a = i.getInstance(key)
            println(a)
        } else {
            println("不存在")
        }
    }

    @Test
    def void ymlTest() {
        println("结果:")
        println(new YamlUtils(new Base64()).toProperties(new FileInputStream("./config/application-dev.yml"), null))
    }

    @Test
    def void cryptoTest() {
        var str = "taomu-rcmu#2025";
        println(new String(new Base64().setData(str.bytes).encode, "UTF-8"))
    }
}
